//用于显示测试执行记录的panel(里面装填了两个grid)
var testRunLogPanel = Ext.create('Ext.panel.Panel', {
    header: false,
    border: false,
    layout: {
        type: 'vbox',// 子容器垂直排列
        align: 'stretch'// 将子项目水平拉伸以填充容器的宽度
    },
    items: [testRunLogGrid, testRunLogStepGrid]
});

// 用于显示测试执行三个板块的tabPanel
var testRunTabPanel = Ext.create('Ext.tab.Panel', {
    defaults: {
        layout: 'fit'
    },
    items: [{
        title: '详细信息',
        items: [testRunDetailForm]
    }, {
        title: '执行记录',
        items: [testRunLogPanel]
    }, {
        title: '审核记录',
        items: [testRunCheckLogGrid]
    }],
    buttons: [{
        itemId: 'testRunCommitButton',
        text: '保存并提交',
        tooltip: '添加即拿去审核',
        listeners: [{
            click: function () {
                testRunSave(1);
            }
        }]
    }, {
        itemId: 'testRunSaveButton',
        text: '保存',
        tooltip: '保存',
        listeners: [{
            click: function () {
                testRunSave(0);
            }
        }]
    }],
    listeners: [{
        tabchange: function (tabPanel, newCard, oldCard, eOpts) {
            if (newCard.title == '审核记录') {
                var item = testRunLeftTree.getSelectionModel().getSelected();// 得到被选择的行的数组.
                testRunCheckLogStore.proxy.url = zuulUrl + '/' + testServiceName + '/testRunCheck/common/' + item.items[0].data.id;
                testRunCheckLogStore.reload();
                testRunTabPanel.down('#testRunCommitButton').setHidden(true);//审核记录不应该提供这两个按钮
                testRunTabPanel.down('#testRunSaveButton').setHidden(true);
            } else {
                if (testRunCreateOrUpdate == 0 || testRunTabPanel.canUpdate) {//点击回其他板块的话就要再根据情况看看要不要显示两个按钮
                    testRunTabPanel.down('#testRunCommitButton').setHidden(false);
                    testRunTabPanel.down('#testRunSaveButton').setHidden(false);
                }
            }
        }
    }]
});

// 用于显示供测试执行选择关联的测试计划的TreeGrid
var testRunDesignTreePanel = Ext.create('Ext.tree.Panel', {
    store: testRunChooseDesignStore,
    rootVisible: false,
    useArrows: true,// 是否用箭头
    header: false,
    listeners: {
        beforeitemexpand: function (node, eOpts) {
            if (node.data.id != 'root')
                testRunDesignGetChildren(node);
        },
        itemdblclick: function (view, record, item, index, e, eOpts) {
            if (!record.data.leaf)
                Ext.Msg.alert("错误", "请选择叶子节点！");
            else {
                testRunDetailForm.down('#testRunDetailFormTestDesign').testDesign = record.data.id;
                testRunDetailForm.down('#testRunDetailFormTestDesign').setValue(getItemInTreePath(testRunChooseDesignStore,record));
                testRunDesignTreeGridWin.hide();
            }
        }
    }
});
